<%@ page  language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8" %>
<form onsubmit="return toSaveRoom()" id="roomForm" lay-filter="roomForm" class="layui-form" style="display: none;padding:10px;" enctype="multipart/form-data">
    <%--   名称--%>
    <div class="layui-form-item">
        <label class="layui-form-label">影厅名称</label>
        <div class="layui-input-block">
            <input type="text" name="roomName"  id="roomName" required  lay-verify="required" placeholder="请输入影厅名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <%--    按钮--%>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn btn-submit"   lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    function toSaveRoom(){
        if($('#roomName').val()==null){
            layer.msg('请输入名称',{icon:0})
        }else {
            $.get("saveRoom",
                {
                    roomName:$('#roomName').val()
                }
                ,function (code){
                    if(code==1){
                        layer.msg('保存成功', {icon: 1});
                    }else if(code==2){
                        layer.msg('名称重复',{icon:0});
                    } else {
                        layer.msg('添加失败',{icon:0});
                    }
                    function reload(){window.location.reload();}
                    window.setTimeout(reload,1000);

                })
        }
        return false;
    }
</script>
